var t = getApp();

Page({
    data: {
        pretext: "",
        key: "",
        nowText: "",
        originText: "",
        From: "",
        Back: "",
        word: "",
        url: "",
        id: "",
        sessin: "",
        condition: !0
    },
    onLoad: function(t) {
        this.setData({
            key: t.key,
            From: t.From,
            Back: t.Back,
            word: t.word,
            url: t.url,
            id: t.id,
            sessin: t.sessin
        }), "parties" != t.key && "Signature" != t.key || this.setData({
            condition: !1
        });
    },
    onReady: function() {
        this.data.pretext;
        var e = this.data.key, a = this.data.From;
        if (1 == this.data.Back) i = wx.getStorageSync(e); else var i = t.globalData.htGet[e];
        1 == a ? this.setData({
            pretext: wx.getStorageSync(e),
            originText: wx.getStorageSync(e)
        }) : 2 == a ? this.setData({
            pretext: t.globalData.htGet[e],
            originText: t.globalData.htGet[e]
        }) : this.setData({
            pretext: t.globalData.tempDetail,
            originText: i
        });
        var r = "def_" + this.data.key;
        wx.getStorageSync(r) || wx.request({
            url: t.url + "addon/Defdetail/Defdetail/" + t.globalData.ItemrefUrl,
            data: {
                keyname: this.data.key
            },
            method: "GET",
            header: {
                "content-type": "application/json",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(t) {
                wx.setStorageSync(r, t.data.deftext);
            }
        });
    },
    formSubmit: function(e) {
        var a = e.detail.value.text, i = this.data.key, r = this.data.url;
        1 == this.data.Back ? (wx.setStorageSync(i, a), wx.redirectTo({
            url: "../SdrafTable/SdrafTable"
        })) : (t.globalData.htGet[i] = a, t.globalData.alternot = 1, wx.redirectTo({
            url: "../MyShtedit/MyShtedit?url=" + r
        }));
    },
    toRefer: function() {
        var e = this.data.nowText, a = this.data.pretext;
        t.globalData.tempDetail = e || a;
    },
    pageClose: function() {
        var e = this.data.nowText, a = this.data.key, i = this.data.pretext, r = this.data.originText, o = (this.data.key, 
        this.data.url), d = this.data.id, n = this.data.sessin, s = (this.data.From, this.data.Back);
        if (1 == s) l = "../SdrafTable/SdrafTable"; else var l = "../MyShtedit/MyShtedit?id=" + d + "&url=" + o + "&sessin=" + n;
        e ? wx.showModal({
            title: "提示",
            content: "你正在“关闭页面”，是否保存修改的数据？",
            confirmText: "保存",
            cancelText: "不保存",
            success: function(i) {
                i.confirm ? 1 == s ? (wx.setStorageSync(a, e), wx.redirectTo({
                    url: "../SdrafTable/SdrafTable"
                })) : (t.globalData.htGet[a] = e, t.globalData.alternot = 1, wx.redirectTo({
                    url: "../MyShtedit/MyShtedit?id=" + d + "&url=" + o + "&sessin=" + n
                })) : wx.redirectTo({
                    url: l
                });
            }
        }) : e || i === r ? wx.redirectTo({
            url: l
        }) : wx.showModal({
            title: "提示",
            content: "你正在“关闭页面”，是否保存修改的数据？",
            confirmText: "保存",
            cancelText: "不保存",
            success: function(e) {
                e.confirm ? 1 == s ? (wx.setStorageSync(a, i), wx.redirectTo({
                    url: "../SdrafTable/SdrafTable"
                })) : (t.globalData.htGet[a] = i, t.globalData.alternot = 1, wx.redirectTo({
                    url: "../MyShtedit/MyShtedit?id=" + d + "&url=" + o + "&sessin=" + n
                })) : wx.redirectTo({
                    url: l
                });
            }
        });
    },
    Default: function() {
        var e = this, a = "def_" + this.data.key, i = wx.getStorageSync(a);
        i ? this.setData({
            pretext: i,
            nowText: i
        }) : wx.request({
            url: t.url + "addon/Defdetail/Defdetail/" + t.globalData.ItemrefUrl,
            data: {
                keyname: this.data.key
            },
            method: "GET",
            header: {
                "content-type": "application/json",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(t) {
                e.setData({
                    pretext: t.data.deftext,
                    nowText: t.data.deftext
                }), wx.setStorageSync(a, t.data.deftext);
            },
            fail: function(t) {
                wx.showToast({
                    title: "连接网络失败",
                    icon: "loading",
                    duration: 2e3
                });
            }
        });
    },
    bindValueinput: function(t) {
        this.setData({
            nowText: t.detail.value
        });
    }
});